package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.MovieNewsDTO;
import com.lcf.system.query.MovieNewsPageQuery;
import com.lcf.system.service.MovieNewsService;
import com.lcf.system.vo.MovieNewsVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 电影资讯(MovieNews)表控制层
 *
 * @author lcf
 * @since 2025-05-07 22:23:22
 */
@Tag(name = "资讯")
@RestController
@RequestMapping("movieNews")
public class MovieNewsController {
    @Resource
    private MovieNewsService movieNewsService;

    /**
     * 新增
     */
    @Operation(summary = "新增资讯")
    @SaCheckPermission("movie:news:add")
    @PostMapping
    public void add(@RequestBody @Validated MovieNewsDTO dto) {
        movieNewsService.add(dto);
    }

    /**
     * 修改
     */
    @Operation(summary = "修改资讯")
    @SaCheckPermission("movie:news:edit")
    @PatchMapping("{id}")
    public void edit(@PathVariable @Schema(description = "资讯ID") long id,
                     @RequestBody @Validated MovieNewsDTO dto) {
        movieNewsService.edit(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除资讯")
    @SaCheckPermission("movie:news:delete")
    @DeleteMapping("{id}")
    public void delete(@PathVariable @Schema(description = "资讯ID") long id) {
        movieNewsService.delete(id);
    }

    /**
     * 资讯分页列表
     */
    @Operation(summary = "资讯分页列表")
    @GetMapping("page")
    public PageVO<MovieNewsVO> page(MovieNewsPageQuery query) {
        return movieNewsService.page(query);
    }

    /**
     * 资讯详情
     */
    @Operation(summary = "资讯详情")
    @GetMapping("{id}")
    public MovieNewsVO get(@PathVariable @Schema(description = "资讯ID") long id) {
        return movieNewsService.get(id);
    }
}

